package adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

import bean.VideoBean;
import jiyun.com.yiyanmeng.R;

/**
 * Created by 裘翔 on 2019/11/6.
 */

public class VideoAdaper extends RecyclerView.Adapter<VideoAdaper.ViewHolder>{
    private Context context;
    private ArrayList<VideoBean.KechengBean> list;

    public VideoAdaper(Context context, ArrayList<VideoBean.KechengBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public VideoAdaper.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.video_item, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull VideoAdaper.ViewHolder holder, int position) {
        holder.video_monery.setText(list.get(position).getYuan_jia_ge());
        holder.video_name.setText(list.get(position).getName());
        holder.video_hour.setText(list.get(position).getClass_hour());
        Glide.with(context).load(list.get(position).getPic()).into(holder.video_iv);
        holder.video_str.setText(list.get(position).getType_str().get(0));

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView video_iv;
        TextView video_name;
        TextView video_str;
        TextView video_hour;
        TextView video_monery;
        public ViewHolder(View itemView) {
            super(itemView);
            video_iv=itemView.findViewById(R.id.video_iv);
            video_name=itemView.findViewById(R.id.video_name);
            video_str=itemView.findViewById(R.id.video_str);
            video_hour=itemView.findViewById(R.id.video_hour);
            video_monery=itemView.findViewById(R.id.video_monery);
        }
    }
}
